package vip.xiaonuo.smzq.modular.psba.controller;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.psba.entity.PsbaSqjl;
import vip.xiaonuo.smzq.modular.psba.entity.vo.Fyfxxtb;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaSqjlCount;
import vip.xiaonuo.smzq.modular.psba.entity.vo.PsbaSqjlVo;
import vip.xiaonuo.smzq.modular.psba.entity.vo.Yfjbxxtb;
import vip.xiaonuo.smzq.modular.psba.service.IPsbaSqjlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;


/**
 * 评审备案申请记录表
 *
 * @author Kevin
 * @since 2024-06-11
 */
@Api(tags = "评审备案申请记录表")
@RestController
@RequestMapping("/psba/psbaSqjl")
@Validated
public class PsbaSqjlController {

    @Resource
    private IPsbaSqjlService iPsbaSqjlService;

    /**
     * 添加评审备案申请记录表
     */
    @ApiOperation("添加评审备案申请记录表")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid PsbaSqjl psbaSqjl) {
        iPsbaSqjlService.save(psbaSqjl);
        return CommonResult.ok();
    }

    /**
     * 删除评审备案申请记录表
     */
    @ApiOperation("删除评审备案申请记录表")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iPsbaSqjlService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑评审备案申请记录表
     */
    @ApiOperation("编辑评审备案申请记录表")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid PsbaSqjl psbaSqjl) {
        iPsbaSqjlService.updateById(psbaSqjl);
        return CommonResult.ok();
    }

    /**
     * 评审备案申请审批表分页查询
     */
//    @ApiOperation("评审备案申请审批表分页查询")
//    @GetMapping("/psbaSqjlList_bak")
//    public CommonResult<Page<PsbaSqjlVo>> psbaSqjlList(
//            @ApiParam(name = "current", value = "页数", example = "1", required = true)  @RequestParam long current,
//            @ApiParam(name = "size", value = "每页数量", example = "20", required = true) @RequestParam long size,
//            String xzqhdm,String shzt,String fqrxm) {
//        return CommonResult.data(iPsbaSqjlService.psbaSqjlList(current, size, xzqhdm,shzt, fqrxm));
//    }

    /**
     * 评审备案申请审批表分页查询-重构
     *
     * @param current
     * @param size
     * @param xzqhdm
     * @param shzt
     * @param fqrxm
     * @author Kevin
     * @since 2024/7/18 14:47
     */
    @ApiOperation("评审备案申请审批表分页查询")
    @GetMapping("/psbaSqjlList")
    public CommonResult<Page<PsbaSqjlVo>> psbaSqjlPage(
            @ApiParam(name = "current", value = "页数", example = "1", required = true) @RequestParam long current,
            @ApiParam(name = "size", value = "每页数量", example = "20", required = true) @RequestParam long size,
            @ApiParam(name = "xzqhdm", value = "行政区划代码") @RequestParam(required = false) String xzqhdm,
            @ApiParam(name = "shzt", value = "审核状态（0审核中，1已完成）") @RequestParam(required = false) String shzt,
            @ApiParam(name = "fqrxm", value = "发起人姓名") @RequestParam(required = false) String fqrxm) {
        return CommonResult.data(iPsbaSqjlService.psbaSqjlPage(current, size, xzqhdm, shzt, fqrxm));
    }

    /**
     * 评审备案申请审批表分页查询的数量查询
     */
    @ApiOperation("评审备案申请审批表分页查询的数量查询")
    @GetMapping("/psbaSqjlCount")
    public CommonResult<PsbaSqjlCount> psbaSqjlCount(@RequestParam(required = false) String xzqhdm, @RequestParam(required = false) String fqrxm) {
        return CommonResult.data(iPsbaSqjlService.psbaSqjlCount(xzqhdm, fqrxm));
    }


    /**
     * 添加评审备案-压覆申请记录表
     */
    @ApiOperation("添加评审备案-压覆申请记录表")
    @PostMapping("/addYfjbqksq")
    public CommonResult<String> addYfjbqksq(@RequestBody @Valid Yfjbxxtb yfjbxxtb) {
        iPsbaSqjlService.addYfjbqksq(yfjbxxtb);
        return CommonResult.ok();
    }

    /**
     * 添加评审备案-非压覆申请记录表
     */
    @ApiOperation("添加评审备案-非压覆申请记录表")
    @PostMapping("/addFyfjbqksq")
    public CommonResult<String> addFyfjbqksq(@RequestBody @Valid Fyfxxtb fyfxxtb) {
        iPsbaSqjlService.addFyfjbqksq(fyfxxtb);
        return CommonResult.ok();
    }

    @ApiOperation("评审备案报告文件预览")
    @GetMapping("/preview")
    public void preview(@ApiParam(name = "fileId", value = "文件ID") @RequestParam String fileId,
                        HttpServletResponse response) {
        iPsbaSqjlService.fileShow(fileId, response);
    }
}
